package com.atguigu.mock.entity;

import com.atguigu.common.base.entity.AutoIdBase;
import com.atguigu.common.comment.Comment;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Entity
@Getter
@Setter
@NoArgsConstructor
@Comment("支付表")
public class Payment extends AutoIdBase {
    @Comment("下单用户")
    @ManyToOne(optional = false)
    private Customer customer;

    @Comment("下单店铺")
    @ManyToOne(optional = false)
    private Shop shop;

    @Comment("订单ID")
    @ManyToOne(optional = false)
    private OrderInfo orderInfo;

    @Comment("金额")
    private BigDecimal amount;

    @Comment("支付状态 1.未支付 2.支付成功 3.支付失败 4.发起退款 5.退款完成")
    private Integer status;


    public Payment(LocalDateTime currentTime, OrderInfo orderInfo) {
        super(currentTime);
        this.customer = orderInfo.getCustomer();
        this.shop = orderInfo.getShop();
        this.amount = orderInfo.getActualAmount();
        this.status = 1;
        this.orderInfo = orderInfo;
    }

}
